package com.CloudDream.Command.Admin;

import com.CloudDream.Inventory.InventoryItem;
import com.CloudDream.MoonCake;
import com.handy.lib.command.IHandyCommandEvent;
import com.handy.lib.util.BaseUtil;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;

public class AddCommand implements IHandyCommandEvent {

    @Override
    public String command() {
        return "add";
    }

    @Override
    public String permission() {
        return "mooncake.add";
    }

    @Override
    public void onCommand(CommandSender commandSender, Command command, String s, String[] args) {
        if(BaseUtil.isPlayer(commandSender).booleanValue()){
            commandSender.sendMessage(MoonCake.prefix + "§c该指令只能由控制台使用");
            return;
        }
        Player p = Bukkit.getPlayer(args[1]);
        (new BukkitRunnable(){
            @Override
            public void run() {
                switch (args[2]) {
                    case "lr":
                        p.getInventory().addItem(InventoryItem.getMoonCake(0));
                        p.sendMessage(MoonCake.prefix + "§a你获得了一个莲蓉月饼");
                        break;
                    case "wr":
                        p.getInventory().addItem(InventoryItem.getMoonCake(1));
                        p.sendMessage(MoonCake.prefix + "§a你获得了一个五仁月饼");
                        break;
                    case "dh":
                        p.getInventory().addItem(InventoryItem.getMoonCake(2));
                        p.sendMessage(MoonCake.prefix + "§a你获得了一个蛋黄月饼");
                        break;
                    case "bt":
                        p.getInventory().addItem(InventoryItem.getMoonCake(3));
                        p.sendMessage(MoonCake.prefix + "§a你获得了一个冰糖月饼");
                        break;
                    case "mg":
                        p.getInventory().addItem(InventoryItem.getMoonCake(4));
                        p.sendMessage(MoonCake.prefix + "§a你获得了一个玫瑰月饼");
                        break;
                    case "gw":
                        p.getInventory().addItem(InventoryItem.getMoonCake(5));
                        p.sendMessage(MoonCake.prefix + "§a你获得了一个果味月饼");
                        break;
                    case "rs":
                        p.getInventory().addItem(InventoryItem.getMoonCake(6));
                        p.sendMessage(MoonCake.prefix + "§a你获得了一个肉松月饼");
                        break;
                }
            }
        }).runTaskAsynchronously(MoonCake.getInstance());
    }
}
